-
-
Notifications
You must be signed in to change notification settings - Fork 44
feat: add support for Apple embedded platforms (iOS, tvOS, watchOS, visionOS) #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for Apple embedded platforms (iOS, tvOS, watchOS, visionOS) #308
Conversation
…isionOS) Apple embedded platforms do not support dynamic library loading due to security restrictions. This adds a cfg attribute to return an empty string for make_system_specific_name() on these platforms, which prevents DSO plugin loading while still allowing bundled plugins (com.worksap.nlp.sudachi.*) to work normally. Tested with: - cargo build -p sudachi --target aarch64-apple-ios - cargo build -p sudachi --target aarch64-apple-ios-sim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for Apple embedded platforms (iOS, tvOS, watchOS, visionOS) by preventing dynamic library loading on these platforms where it's not supported due to security restrictions. The change allows sudachi.rs to be used in mobile and embedded Apple applications while maintaining support for bundled plugins.
Key changes:
- Added platform-specific implementation of
make_system_specific_name()that returns an empty string for Apple embedded platforms
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- UniFFI-based Swift bindings for sudachi.rs morphological analyzer - Support for iOS 13+ and macOS 10.15+ (stable) - Nightly builds for tvOS, watchOS, visionOS - Bundled resources (char.def, unk.def, sudachi.json) - Examples: BasicUsage (macOS) and iOSApp (iOS) - CI/CD: build.yml for testing, release.yml for publishing - CocoaPods and Swift Package Manager support Note: Using fork of sudachi.rs with iOS platform support PR: WorksApplications/sudachi.rs#308
hayashi-mas-wap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR. There are no issues with the functionality, but I have some requests regarding code improvements.
sudachi/src/plugin/loader.rs
Outdated
| } | ||
|
|
||
| #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] | ||
| fn make_system_specific_name(_s: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will let fn system_specific_name return a path to a directory and it may cause a problem.
I want you to change the signature of make_system_specific_name to fn (&str) -> Option<String> and let the variable fname (in l.80) to be None in those target OSs.
Co-authored-by: Copilot <[email protected]>
- Change signature from fn(&str) -> String to fn(&str) -> Option<String> - Return None for Apple embedded platforms instead of empty string - Use and_then instead of map in system_specific_name for proper Option chaining Addresses review feedback from @hayashi-mas-wap
|
Thank you for the review feedback! I've updated the implementation as suggested:
This ensures that |
hayashi-mas-wap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!!
@hayashi-mas-wap |
Summary
Add support for compiling sudachi on Apple embedded platforms (iOS, tvOS, watchOS, visionOS).
Changes
Apple embedded platforms do not support dynamic library loading due to security restrictions. This adds a
#[cfg]attribute to return an empty string formake_system_specific_name()on these platforms, which prevents DSO plugin loading while still allowing bundled plugins (com.worksap.nlp.sudachi.*) to work normally.Motivation
Enable sudachi.rs to be used in iOS/tvOS/watchOS/visionOS applications via Swift bindings (UniFFI).
Testing
cargo build -p sudachi --target aarch64-apple-ioscompiles successfullycargo build -p sudachi --target aarch64-apple-ios-simcompiles successfully